package com.tongzhou.client;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
 
public class Eddy implements Runnable{
 
    private static HttpURLConnection conn;
    public  Eddy(){   //constructor
     
    }
    public void run(){
     connection();
    }
   
   protected void connection(){
 try{
//    URL url=new URL("http://www.taobao.com");
    URL url=new URL("http://www.tongzhoudg.com/tongzhouClient/client.do?method=1&json={'companyName':'佛山市南海中艺联发彩印包装厂','companyNum':'ZYLF01'}");
    conn=(HttpURLConnection)url.openConnection();
    conn.setRequestMethod("POST");
    System.out.println(1111);
    System.out.println("statecode:"+conn.getResponseCode());   //得到服务器端响应码
    System.out.println(1111);
    System.out.println("Type:"+conn.getContentType());  //得到网页文件类型
    System.out.println("Length:"+conn.getContentLength());
    System.out.println("Time:"+conn.getExpiration());
    System.out.println("Time:"+conn.getReadTimeout());
    System.out.println("LastModified"+conn.getLastModified());
    System.out.println(InputStreamtoString(conn.getInputStream()).trim());
 }
 catch(MalformedURLException ex){
  ex.printStackTrace();
     System.err.println("MalformedURLException");
 }
 catch(IOException ea){
  ea.printStackTrace();
  System.err.println("IOException");
 }
   
   }
   public static String InputStreamtoString(InputStream in) throws IOException {
		StringBuffer out = new StringBuffer();
		
		byte[] buffer = new byte[1024];
		
		for (int i; (i = in.read(buffer)) != -1;) 
		{
			out.append(new String(buffer, 0, i));
		}
		
		return out.toString();
	}
 public static void main(String args[]){
  Thread t=new Thread(new Eddy());
  t.start();
  
  
 
 }
}
